package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.Livebroadcastingroom;
import com.ruoyi.system.service.ILivebroadcastingroomService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 直播间信息Controller
 * 
 * @author kinglu
 * @date 2021-11-30
 */
@RestController
@RequestMapping("/Livebroadcastingroom")
public class LivebroadcastingroomController extends BaseController
{
    @Autowired
    private ILivebroadcastingroomService livebroadcastingroomService;

    /**
     * 查询直播间信息列表 直播列表 筛选 魏俊文 2021-12-2
     */
    //@RequiresPermissions("system:Livebroadcastingroom:list")
    @GetMapping("/list")
    public TableDataInfo list(Livebroadcastingroom livebroadcastingroom)
    {
        startPage();
        List<Livebroadcastingroom> list = livebroadcastingroomService.selectLivebroadcastingroomList(livebroadcastingroom);
        return getDataTable(list);
    }

    /**
     * 导出直播间信息列表
     */
    @RequiresPermissions("system:Livebroadcastingroom:export")
    @Log(title = "直播间信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Livebroadcastingroom livebroadcastingroom)
    {
        List<Livebroadcastingroom> list = livebroadcastingroomService.selectLivebroadcastingroomList(livebroadcastingroom);
        ExcelUtil<Livebroadcastingroom> util = new ExcelUtil<Livebroadcastingroom>(Livebroadcastingroom.class);
        util.exportExcel(response, list, "直播间信息数据");
    }

    /**
     * 获取直播间信息详细信息
     */
    @RequiresPermissions("system:Livebroadcastingroom:query")
    @GetMapping(value = "/{roomId}")
    public AjaxResult getInfo(@PathVariable("roomId") Long roomId)
    {
        return AjaxResult.success(livebroadcastingroomService.selectLivebroadcastingroomByRoomId(roomId));
    }

    /**
     * 新增直播间信息
     */
    @Log(title = "直播间信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Livebroadcastingroom livebroadcastingroom)
    {
        return toAjax(livebroadcastingroomService.insertLivebroadcastingroom(livebroadcastingroom));
    }

    /**
     * 修改直播间信息
     */
    @RequiresPermissions("system:Livebroadcastingroom:edit")
    @Log(title = "直播间信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Livebroadcastingroom livebroadcastingroom)
    {
        return toAjax(livebroadcastingroomService.updateLivebroadcastingroom(livebroadcastingroom));
    }

    /**
     * 删除直播间信息
     */
    @RequiresPermissions("system:Livebroadcastingroom:remove")
    @Log(title = "直播间信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomIds}")
    public AjaxResult remove(@PathVariable Long[] roomIds)
    {
        return toAjax(livebroadcastingroomService.deleteLivebroadcastingroomByRoomIds(roomIds));
    }
}
